import i18n from '@/i18n'
import { hasPermission } from '@/utils'
import { timeFormat } from '@/components/storybook/utilties/tools'
import {
  RenderGuestUser,
  HomeChannel,
  Status,
  ManagerFormat,
  Role,
  Action,
  MessageSwitch
} from './elements'

export const renderColumns = (connectorSetting = {}) =>
  Object.freeze([
    {
      type: 'checkbox',
      allowFiltering: false,
      allowSorting: false,
      width: 46
    },
    {
      field: 'username',
      headerText: i18n.t('user.username')
    },
    {
      headerText: 'Action',
      width: 100,
      textAlign: 'Center',
      visible: hasPermission('sys:user:update'),
      template: Action
    },
    {
      headerText: i18n.t('user.firstName'),
      width: 120,
      field: 'firstName'
    },
    {
      headerText: i18n.t('user.lastName'),
      width: 120,
      field: 'lastName'
    },
    {
      headerText: i18n.t('user.message'),
      width: 160,
      field: 'teamsMessageSwitch',
      template: MessageSwitch
    },
    {
      headerText: i18n.t('user.role'),
      width: 120,
      field: 'roles',
      template: Role
    },
    {
      headerText: i18n.t('user.managerName'),
      width: 120,
      field: 'managerName',
      template: ManagerFormat
    },
    {
      headerText: i18n.t('user.status'),
      width: 100,
      field: 'status',
      template: Status
    },
    {
      headerText: i18n.t('user.deptName'),
      width: 120,
      field: 'deptName'
    },
    {
      headerText: i18n.t('user.mobile'),
      width: 150,
      field: 'mobile'
    },
    {
      headerText: i18n.t('user.email'),
      width: 200,
      field: 'email'
    },
    {
      headerText: i18n.t('user.jobTitle'),
      width: 200,
      field: 'jobTitle'
    },
    {
      headerText: i18n.t('user.officeLocation'),
      width: 200,
      field: 'officeLocation'
    },

    {
      headerText: i18n.t('user.homeChannel'),
      width: 200,
      template: HomeChannel
    },
    {
      field: 'teamsUserId',
      headerText: i18n.t('user.teamsUserId'),
      width: 200,
      visible: connectorSetting['TEAMS']
    },
    {
      field: 'cwUserName',
      headerText: i18n.t('user.cwUserName'),
      width: 200,
      visible: connectorSetting['CW']
    },
    {
      field: 'tsheetUserName',
      headerText: i18n.t('user.tsheetUserName'),
      width: 230,
      visible: connectorSetting['TSHEET']
    },
    {
      field: 'timedoctorUserName',
      headerText: i18n.t('user.timeDoctorUserName'),
      width: 260,
      visible: connectorSetting['TD']
    },
    {
      field: 'autoTaskUserName',
      headerText: i18n.t('user.autotaskUserName'),
      width: 260,
      visible: connectorSetting['AUTOTASK']
    },
    {
      field: 'syncroUserName',
      headerText: i18n.t('user.syncroUserName'),
      width: 260,
      visible: connectorSetting['SYNCROMSP']
    },
    {
      field: 'isGuestUser',
      headerText: i18n.t('user.isGuestUser'),
      width: 150,
      template: RenderGuestUser,
      textAlign: 'Center'
    },
    {
      field: 'createDate',
      headerText: i18n.t('user.createDate'),
      width: 180,
      format: value => timeFormat(value)
    },
    {
      field: 'updateDate',
      headerText: i18n.t('user.updateDate'),
      width: 180,
      format: value => timeFormat(value)
    },
    {
      field: 'lastLoginTime',
      headerText: i18n.t('user.lastLoginDate'),
      width: 180,
      format: value => timeFormat(value)
    }
  ])
